package com.ssy.lingxi.product.controller.mobile;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.product.api.model.request.warehouse.*;
import com.ssy.lingxi.product.api.model.response.warehouse.InvoicesTypeListResponse;
import com.ssy.lingxi.product.service.InvoicesTypeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @menu APP-进销存-单据类型管理
 * @author wrc
 * @date 2020/7/20
 */
@RestController
@RequestMapping("/product/mobile")
public class MobileInvoicesTypeController extends BaseController {
    @Resource
    InvoicesTypeService invoicesTypeService;

    @ApiOperation(value = " APP-单据类型列表查询")
    @GetMapping("/invoices/type/list")
    public Wrapper<PageData<InvoicesTypeListResponse>> invoicesTypeList(InvoicesTypeListRequest request) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return invoicesTypeService.invoicesTypeList(request,sysUser);
    }

    @ApiOperation(value = " APP-单据类型详情查询")
    @GetMapping("/invoices/type/details")
    public Wrapper<InvoicesTypeListResponse> invoicesTypeDetails(Long id) {
        return invoicesTypeService.invoicesTypeDetails(id);
    }

    @ApiOperation(value = " APP-查询单据类型全部")
    @GetMapping("/invoices/type/all")
    public Wrapper<List<InvoicesTypeListResponse>> invoicesTypeAll(HttpServletRequest httpServletRequest) {
        UserLoginCacheDTO sysUser = this.getSysUser(httpServletRequest);
        return invoicesTypeService.invoicesTypeAll(sysUser);
    }

    @ApiOperation(value = " APP-单据类型删除")
    @GetMapping("/invoices/type/delete")
    public Wrapper<Void> invoicesTypeDelete(Long id) {
        return invoicesTypeService.invoicesTypeDelete(id);
    }

    @ApiOperation(value = " APP-单据类型增加/修改")
    @PostMapping("/invoices/type/addOrUpdate")
    public Wrapper<Void> invoicesTypeAddOrUpdate(@RequestBody InvoicesTypeAddOrUpdateRequest request) {
        UserLoginCacheDTO sysUser = this.getSysUser();
        return invoicesTypeService.invoicesTypeAddOrUpdate(request,sysUser);
    }

    @ApiOperation(value = " APP-单据类型停用&启用")
    @PostMapping("/invoices/type/startOrStop")
    public Wrapper<Void> invoicesTypeStartOrStop(@RequestBody InvoicesTypeStateUpdateRequest request) {
        return invoicesTypeService.invoicesTypeStartOrStop(request);
    }
}
